﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using POSSystem.DAL;

namespace POSSystem.BLL
{
    public class LoanPhones : _LoanPhones
    {
        public static LoanPhones GetLoanPhones(string ids)
        {
            LoanPhones phones = new LoanPhones();
            phones.Where.ID.Value = ids;
            phones.Where.ID.Operator = MyGeneration.dOOdads.WhereParameter.Operand.In;
            phones.Query.Load();

            return phones;
        }

        public static LoanPhones LoadActiveLoanPhone()
        {
            LoanPhones phones = new LoanPhones();
            phones.Where.Deleted.Value = false;
            phones.Query.Load();

            return phones;
        }

        public static LoanPhones GetLoanPhoneByIMEI(string imei)
        {
            LoanPhones phones = new LoanPhones();
            phones.Where.IMEI.Value = imei;
            phones.Query.Load();

            return phones;
        }

        public static LoanPhones GetLoanPhoneById(int id)
        {
            LoanPhones phones = new LoanPhones();
            phones.LoadByPrimaryKey(id);

            return phones;
        }

        public static void DeleteLoanPhones(string ids)
        {
            if (ids == "")
                ids = "-1";
            LoanPhones phones = new LoanPhones();
            phones.Where.ID.Value = ids;
            phones.Where.ID.Operator = MyGeneration.dOOdads.WhereParameter.Operand.In;
            phones.Query.Load();

            for (int i = 0; i < phones.RowCount; i++)
            {
                phones.Deleted = true;
                phones.MoveNext();
            }

            phones.Save();
        }
    }
}
